<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<input type="text">
<input type="button" value="凤凰单车" onclick="f(1)">
<input type="button" value="美景" onclick="f(2)">
<script>
    /*let img = document.createElement("img");
    img.src="cozy.jpg"
    document.body.append(img);*/
//1获取数字
    //2.循环(每一个图片创建一个img标签)
    let input = document.querySelector("input");
    input.value
    function f(x) {
        /*根据传进来的x值选择不同的图片路径*/
        let src=x==1?"cozy.jpg":"garden.jpg";
            /*条件?值1:值2*/
        for (let i = 0; i < input.value; i++) {
        let img = document.createElement("img")
        img.src=src;
        document.body.append(img);

        }
    }
</script>
</body>
</html>